package com.midea.ai.air.ui.more.fragment;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.midea.ai.air.R;
import com.midea.ai.air.ui.more.MoreSettingAirReport;
import com.midea.ai.air.ui.more.MoreSettingAirReportIndoorDetail;
import com.midea.ai.air.view.AirReportChartView;

import java.util.ArrayList;

/**
 * Created by hww on 2016/4/13.
 */
public class MoreSettingAirReportDayFragment extends Fragment implements View.OnClickListener {

    private AirReportChartView indoor_temp, indoor_humidity, indoor_PM;


    private static final int SHOW_DAY_INDOOR_TEMP = 0x111;
    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case SHOW_DAY_INDOOR_TEMP:

                    break;
                default:
                    break;
            }
        }
    };

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_air_report_day, container, false);

        initView(view);

        return view;
    }

    private void initView(View view) {
        indoor_temp = (AirReportChartView) view.findViewById(R.id.fragment_air_report_indoor_temp_View);
        indoor_humidity = (AirReportChartView) view.findViewById(R.id.fragment_air_report_indoor_humidity_View);
        indoor_PM = (AirReportChartView) view.findViewById(R.id.fragment_air_report_indoor_PM_View);
        getDatas();

        indoor_temp.setOnClickListener(this);
        indoor_humidity.setOnClickListener(this);
        indoor_PM.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.fragment_air_report_indoor_temp_View:
//                startActivity(new Intent(getActivity(), MoreSettingAirReportIndoorTemp.class));
                startActivity(MoreSettingAirReport.INDOOR_TEMP);
                break;

            case R.id.fragment_air_report_indoor_humidity_View:
                startActivity(MoreSettingAirReport.INDOOR_HUMIDITY);
                break;

            case R.id.fragment_air_report_indoor_PM_View:
                startActivity(MoreSettingAirReport.INDOOR_PM);
                break;

            default:
                break;
        }

    }

    private void startActivity(String Tag) {
        Intent intent = new Intent(getActivity(), MoreSettingAirReportIndoorDetail.class);
        Bundle bundle = new Bundle();
        bundle.putString(MoreSettingAirReport.INDOOR_SELECTED_STRING, Tag);
        intent.putExtras(bundle);
        startActivity(intent);
    }

    ArrayList<Double> yList_two;
    ArrayList<Double> yList_three;

    private void getDatas() {
        ArrayList<Double> yList = new ArrayList<Double>();
        yList.add((double) 2.103);
        yList.add(3.05);
        yList.add(4.60);
        yList.add(2.08);
        yList.add(3.32);
        yList.add(1.0);
        yList.add(3.0);
        yList.add((double) 2.103);
        yList.add(3.05);
        yList.add(4.60);
        yList.add(2.08);
        yList.add(3.32);
        yList.add(1.0);
        yList.add(3.0);
        yList.add((double) 2.103);
        yList.add(3.05);
        yList.add(4.60);
        yList.add(2.08);
        yList.add(3.32);
        yList.add(1.0);
        yList.add(3.0);
        yList.add(3.32);
        yList.add(1.0);
        yList.add(3.0);

        yList_two = new ArrayList<Double>();
        for (int i = 0; i < 14; i++) {
            yList_two.add((double) yList.get(i) + 1);
        }

        yList_three = new ArrayList<Double>();
        for (int i = 0; i < 16; i++) {
            yList_three.add((double) yList.get(i) + 1);
        }

        indoor_temp.setDatas(yList, yList_two, yList_three,
                R.color.air_report_view_indoor_temp_one,
                R.color.air_report_view_indoor_temp_two,
                R.color.air_report_view_indoor_temp_three);

        indoor_humidity.setDatas(yList, yList_two, yList_three,
                R.color.air_report_view_indoor_humidity_one,
                R.color.air_report_view_indoor_humidity_two,
                R.color.air_report_view_indoor_humidity_three);

        indoor_PM.setDatas(yList, yList_two, yList_three,
                R.color.air_report_view_indoor_pm_one,
                R.color.air_report_view_indoor_pm_two,
                R.color.air_report_view_indoor_pm_three);
    }

}
